import {
	createApp
} from 'vue'
import ElementPlus from 'element-plus'

// 日历样式导入
// import '@fullcalendar/core/main.css';
// import '@fullcalendar/daygrid/main.css';
// import '@fullcalendar/timegrid/main.css';

import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/display.css'
import scui from './scui'
import i18n from './locales'
import router from './router'
import store from './store'
import App from './App.vue'
const app = createApp(App);

/*
全局loading
*/
import {
	ElLoading
} from 'element-plus'
// 全局挂载 Loading 方法
let loadingInstance = null
app.config.globalProperties.$showLoading = (options = {}) => {
	loadingInstance = ElLoading.service({
		lock: true,
		text: '加载中...',
		background: 'rgba(0, 0, 0, 0.7)',
		...options
	})
}
app.config.globalProperties.$hideLoading = () => {
	loadingInstance?.close()
}
/*
全局loading
*/

/*
挂载图标
*/
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
	app.component(key, component)
}
/*
挂载图标
*/

/*挂载界面设计器*/
// yarn add @form-create/element-ui@next
// yarn add @form-create/designer@next

import FcDesigner from '@form-create/designer'
app.use(FcDesigner)
app.use(FcDesigner.formCreate)

/* 前端微服务 */

import microApp from '@micro-zoe/micro-app'
import {
	removeDomScope
} from '@micro-zoe/micro-app'

microApp.start({
	'router-mode': 'pure', // 所有子应用都设置为pure模式
})
removeDomScope(true) // 解除元素绑定

/*挂载ai对话框*/
import ElementPlusX from 'vue-element-plus-x'
app.use(ElementPlusX);

/*挂载事件总线*/
import MittPlugin from './plugins/mitt'
app.use(MittPlugin)

/*挂载websocket*/
import WebSocketPlugin from './plugins/websocket'
app.use(WebSocketPlugin)

/* 挂载taui */
import TaUI from './taui/index.js'
app.use(TaUI)

app.use(store);
app.use(router);
app.use(ElementPlus);
app.use(i18n);
app.use(scui);
//挂载app
app.mount('#app');
